home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9868 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Standard question - pointer initialization
  5. Date: 14 Mar 1996 01:44:13 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar13184413@qcd.lanl.gov>
  8. References: <4hk9un$906@hammer.msfc.nasa.gov> <4hl6rr$nde@news.xs4all.nl>
  9.     <313E6028.1C19@ix.netcom.com> <4hnpsl$g8c@hacgate2.hac.com>
  10.     <4hq9hsINN998@keats.ugrad.cs.ubc.ca> <4i7cgn$5da@baygull.rtd.com>
  11. NNTP-Posting-Host: qcd.lanl.gov
  12. Mime-Version: 1.0
  13. Content-Type: text
  14. In-reply-to: collins@RTD.COM's message of 13 Mar 1996 20:51:35 GMT
  15.  
  16. In article <4i7cgn$5da@baygull.rtd.com>
  17. collins@RTD.COM (Ronald Collins) writes:
  18. <snip>
  19. RC: : Also note that NULL is just a macro that stands for the value zero (often
  20. RC: : accompanied by a cast to void *). In assigning default initialization values to
  21. RC: : static variables, the compiler couldn't care less that there is a pre-processor
  22. RC: : macro called NULL. NULL can never be anything other than zero in a
  23. RC: : standard-conforming implementation of the C language.
  24. RC: 
  25. RC: This may be true on _your_ implementation, but nothing in the standard
  26. RC: requires the NULL value to be numerically 0.
  27. RC: 
  28. RC: Please read the FAQ before posting on the subject again.
  29.  
  30. Confusion reigns!
  31.  
  32. NULL is a macro which is defined in a number of standard headers. It
  33. is guaranteed to be an integral constant (roughly, compile time
  34. integral constant which does not depend on floating ot pointer
  35. arithmetic) with the value 0; or such a quantity cast to (void*).
  36.  
  37. Thus it could be 0, (1-1), (void*)0, __builtin_null (with a previous
  38. enum __builtin_tag { __builtin_null }; explicit or assumed), or an
  39. infinity of other forms. However, informally, all of these are zeros.
  40.  
  41. In a context where the compiler _knows_ that a pointer is required,
  42. the compiler shall automatically converted all integral constant zeros
  43. to a null pointer. The representation of this null pointer may
  44. actually depend on its type, and has no relation to zero. This is what
  45. the FAQ file was trying to explain.
  46.  
  47. Cheers
  48. Tanmoy
  49. --
  50. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  51. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  52. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  53. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  54. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  55. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  56.